package excercise;

public class EX35 {
	
	public static void main(String[] args){
		//다못쓴 교슈님꺼
		int pay = 32190;
		int money1 = 146546;
		int charge = money1 - pay;
		//int W50000; int W10000; int W5000; int W1000; int W500; int W100; int W50; int W10;

		/*W50000 = charge / 50000;
		W10000 = charge / 10000;
		W5000 = charge / 5000;
		W1000 = charge / 1000;
		W500 = charge / 500;
		W100 = charge / 100;
		W50 = charge / 50;
		W10 = charge / 10;
		charge = charge % 50000;
		System.out.println("5만원권 :" + W50000);
		System.out.println("1만원권 :" + W10000);
		System.out.println("5천원 :" + W5000);
		System.out.println("1천원 :" + W1000);
		System.out.println("500원 :" + W500);
		System.out.println("100원 :" + W100);*/
	// 만들어본거
	int money = 456410;
	int my = 0;
	int total = 0;
	
	
	System.out.println("잔돈 계산해주는 프로그램");
	
	System.out.println(money + "원에서 필요한 화폐는");
	my = (money / 50000);
	System.out.println("5만원권:" + my + "개");
	total = total + (my * 2);
	if( my > 0)money = money % (my * 50000);
	System.out.println("남은금액" + money + "원");
	my = (money / 10000);
	System.out.println("1만원권:" + my + "개");
	total = total + (my * 3);
	if( my > 0)money = money % (my * 10000);
	System.out.println("남은금액" + money + "원");
	my = (money / 5000);
	System.out.println("5천원권:" + my + "개");
	total = total + (my * 4);
	if( my > 0)money = money % (my * 5000);
	System.out.println("남은금액" + money + "원");
	my = (money / 1000);
	System.out.println("1천원권:" + my + "개");
	total = total + (my * 5);
	if( my > 0)money = money % (my * 1000);
	System.out.println("남은금액" + money + "원");
	my = (money / 500);
	System.out.println("500원 :" + my + "개");
	total = total + (my * 6);
	if( my > 0)money = money % (my * 500);
	System.out.println("남은금액" + money + "원");
	my = (money / 100);
	System.out.println("100원 : " + my + "개" );
	total = total + (my * 7);
	if( my > 0)money = money % (my * 100);
	System.out.println("남은금액 " + money + "원");
	my = (money / 50);
	System.out.println("50원 :" + my + "개");
	total = total + (my * 8);
	if( my > 0)money = money % (my * 50);
	System.out.println("남은금액" + money + "원");
	my = (money / 10);
	System.out.println("10원 : " + my + "개");
	total = total + (my * 9);
	if( my > 0)money = money % (my * 10);
	System.out.println("는" +money + "입니다");
	
	// 반복문, 배열을 이용한 잔돈 처리(교수님꺼)
	int[] charges ={0,0,0,0,0,0,0,0,0};
	int[] moneys = {0,50000,10000,5000,1000,500,100,50,10};
	charge = money1 - pay;
	for(int i = 1; i <= 8; ++i){
		charges[i] = charge / moneys[i];
		charge = charge % moneys[i];
		System.out.println(moneys[i] + "/" + charges[i]);
		
	}
	
}
}
